const webpack = require('webpack');

module.exports = class CssDependency extends webpack.Dependency {
  constructor(
    {
      identifier, content, media, sourceMap,
    },
    context,
    identifierIndex,
  ) {
    super();

    this.identifier = identifier;
    this.identifierIndex = identifierIndex;
    this.content = content;
    this.media = media;
    this.sourceMap = sourceMap;
    this.context = context;
    this.theme = /\btheme=(\w+?)\b/.exec(identifier) && RegExp.$1;
  }

  getResourceIdentifier() {
    return `css-module-${this.identifier}-${this.identifierIndex}`;
  }
};
